﻿using B.S.Sterilizationcenter.Domain.zmc;
using B.S.Sterilizationcenter.ErrorCode;
using B.S.Sterilizationcenter.Read.API.Appliaction.Commends.zmc;
using MediatR;
using SqlSugar;

namespace B.S.Sterilizationcenter.Read.API.Appliaction.CommandHandlers.zmc
{
    public class QueryApparatusDropCommandHandlers : IRequestHandler<QueryApparatusDropCommands, ApiResult<List<Apparatus>>>
    {

        private readonly ISqlSugarClient db;

        public QueryApparatusDropCommandHandlers(ISqlSugarClient db)
        {
            this.db = db;
        }

        /// <summary>
        /// 下拉框显示-多个
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<ApiResult<List<Apparatus>>> Handle(QueryApparatusDropCommands request, CancellationToken cancellationToken)
        {
            ApiResult<List<Apparatus>> result = new ApiResult<List<Apparatus>>();
            result.Code = ApiEnums.查询成功;
            result.Msg = "查询成功";

            var list = db.Queryable<Apparatus>().ToList();

            result.Data = list;

            return result;
        }
    }
}
